package com.itdlc.android.library.utils;

import android.content.Context;
import android.content.Intent;

import java.io.DataOutputStream;
import java.io.IOException;


public class OsUtil {
    public static void restartApp(Context context,Class cls) {
        Intent intent = new Intent(context, cls);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        android.os.Process.killProcess(android.os.Process.myPid());
    }

    public static void reStartOs(){
        try {
            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream out = new DataOutputStream(
                    process.getOutputStream());
            out.writeBytes("reboot \n");
            out.writeBytes("exit\n");
            out.flush();
        } catch (IOException e) {
        }
    }
}
